/** http://www.mazelog.com/show?8D */
#include<bits/stdc++.h>
using namespace std;

int mat[6][6] = {
  {4,4,2,2,2,5},
  {5,1,2,3,1,2},
  {3,3,3,2,3,4},
  {2,1,2,2,3,5},
  {3,3,3,3,4,1},
  {4,3,5,2,5,0}
};
bool stamp[6][6];

// void scanMat() {}
void showMat() {
  for(int i=0; i<6; ++i){ 
    for(int j=0; j<6; ++j){
      cout << mat[i][j] <<" ";
    }
    cout << endl;
  }
}
struct Pos {
  int x,y;
  Pos(int a=0,int b=0):x(a),y(b){}
  bool go() {
    if(stamp[x][y]) return false;
    int dis = mat[x][y];
    if(dis==0) return true;
    if (y - dis >= 0) {
      y -= dis;
      go();
    }
    if (x + dis < 6) {
      x += dis;
      go();
    }
    if (y + dis < 6) {
      y += dis;
      go();
    }
    if (x - dis >= 0) {
      x -= dis;
      go();
    }
    stamp[x][y]=true;
    return true;
  }
  // void 
};

int main() {
  memset(stamp, false, sizeof(stamp));
  Pos p;
  return 0;
}